#!/bin/bash
#直接安装
sudo apt install -y tesseract-ocr
#源码安装
#安装编译安装依赖
sudo apt-get install g++ autoconf automake libtool autoconf-archive pkg-config libpng-dev libjpeg8-dev libtiff5-dev zlib1g-dev
#安装训练工具
sudo apt-get install libicu-dev libpango1.0-dev libcairo2-dev
#安装leptonica
sudo apt-get install libleptonica-dev


git clone https://github.com/tesseract-ocr/tesseract.git
cd tesseract

./autogen.sh
./configure --prefix=$HOME/local/
make
sudo make install
#虽然不明白但是很必要
sudo ldconfig
#训练模块安装
make training
sudo make training-install
#切换至root环境
sudo -s
sudo echo "$HOME/local/lib" > /etc/ld.so.conf.d/caixq.conf

#To install it in $HOME/local using Leptonica libraries also installed in $HOME/local:

./autogen.sh
LIBLEPT_HEADERSDIR=$HOME/local/include ./configure \
  --prefix=$HOME/local/ --with-extra-libraries=$HOME/local/lib
make
make install